$(function(){

	var params = $("#tabContent > .tab-pane.active").data();
	var thead='<table id="caseListTable-sub" class="table display nowrap" style="width:100%;">';
	thead+='</table>';
	$("#"+tabId+" #content").html(thead);
	var param = {"icdType":params.icdType,"icdCode": params.icdCode,"icdDesc":params.icdDesc};
	$.post(contextPath+"/matchIcd/getNoCompareCase.dhc", param).done(function(result){	
		if(result.success){
			var data = result.data;
			var colunms=[
		                 {
		              	   "data": "MRNO","title":'病案号',
		              	   "render": function(obj, type, full){
									var mrNo = full.MRNO;
								return "<a href=\"javascript:medicalRecord('"+full.ID+"','"+full.PATIENTNAME+"')\">"+mrNo+"</a>";
							}
		                 },
		                 { "data": "PATIENTNAME","title":'姓名' },
		                 {
		              	   "data": "SEX","title":'性别',
		              	   "render": function(obj, type, full) {
					               var sex=full.SEX;
					               if(sex == "1"){
					              	 sex = "男";
					               }else if(sex == "2"){
					              	 sex = "女";
					               }else{
					              	 sex = "未知";
					               }
					               return sex;
					           }
		                 },
		                 { "data": "AGEYEAR","title":'年龄' },
		                 { "data": "INDATE","title":'入院时间'},
		                 { "data": "OUTDATE","title":'出院时间'},
		                 { "data": "OUTDEP" ,"title":'出院科室'},
		                 { "data": "INDAYS","title":'住院日' },
		                 { 
		              	   "data": "COSTAMOUNT","title":'总费用(元)', "type":"numeric-comma",
		              	   "render": function(obj, type, full){
		              		   var costamount=dealwithFloat(full.COSTAMOUNT);
		              		   return costamount;
		              	   } 
		              	  
		                 },
		                 { "data": "DIAGNOSECODE","title":'主要诊断ICD' },
		                 { "data": "DIAGNOSEDESSMAIN","title":'主要诊断',"render": function(obj, type, full) {
			            	 return linefeedText(obj);
			             } },
			             { "data": "OTH_DIAGINFO_CODE","title":'其他诊断ICD',"render": function(obj, type, full) {
			            	 return linefeedText(obj);
			             } },
			             { "data": "OTH_DIAGINFO_DESC","title":'其他诊断',"render": function(obj, type, full) {
			            	 return linefeedText(obj);
			             } },
			             { "data": "OPERINFO_CODE","title":'手术操作ICD',"render": function(obj, type, full) {
			            	 return linefeedText(obj);
			             } },
		                 { "data": "OPERINFO_DESC","title":'手术操作',"render": function(obj, type, full) {
			            	 return linefeedText(obj);
			             } }
		                 ];
						var paramsDataTables={pageLength:50,scrollX:true,scrollY:'350px',tableTitle:'未对照病例明细表',lengthMenu:[[ 50,100,500, 1000,99999],[ 50,100,500, 1000,'全部']]};
						var oTable=$("#"+tabId+" #caseListTable-sub").dataTableBasic(colunms,result.data,paramsDataTables);
						$('#'+tabId+' #caseListTable-sub_wrapper .dataTables_scrollBody table tbody').attr('id','table');//tbody加上ID，病案号的样式
						$('#'+tabId+' #caseListTable-sub_wrapper .dataTables_scrollHeadInner table thead th').css({'text-align':'center'});
						
						oTable.columns.adjust();//tbody加了样式，重新调整宽度
		}
		
	});
	
});

function dealwithFloat(number){
	if (number!=null&& "" != number) {
		return formatNumber(Number(number).toFixed(2));
	}
	return "";
}
